package com.dq.security.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author dongqun
 * @Description:
 * @date 2019/1/6 20:07
 */
@Controller
@RequestMapping("/blogs")
public class BlogController {

    @GetMapping("/")
    public String list(){
        return "/blog/list";
    }

    @GetMapping("/delete/{id}")
    @PreAuthorize("hasAuthority('ROLE_admin')")
    public String list(@PathVariable Long id,Model model){
        model.addAttribute("state","第"+id+"篇博客已删除！");
        return "/blog/result";
    }

}
